package com.example.orchid.coordinatorlayoutdemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;

import com.example.orchid.coordinatorlayoutdemo.R;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;


public class SplashActivity extends AppCompatActivity {
    private static final int SHOW_TIME_MIN = 800;// 最小显示时间


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        Observable.timer(SHOW_TIME_MIN, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
                .map(i -> {
                    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.setClass(this, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    finish();
                    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                    return null;
                }).subscribe();
    }

    @Override
    public void onBackPressed() {

    }

}
